﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AdmLaboratorios.Business;
using AdmLaboratorios.DTO;

namespace AdmLaboratorios
{
    public partial class frmValeConsumoSeleccion : Form
    {
        public OrdenProduccionDTO Op { get; set; }
        public ValeConsumoDevolucionDTO Vale { get; set; }

        public frmValeConsumoSeleccion()
        {
            InitializeComponent();
        }

        private void frmValeConsumoSeleccion_Load(object sender, EventArgs e)
        {
            lblOp.Text = Op.ToString();

            ReloadGrid();
        }

        internal void ReloadGrid()
        {
            gv.DataSource = null;
            gv.DataSource = Stock.ConsultaValtes(eValeTipo.CONSUMO.ToString(), Op);
            lblRegistros.Text = ((DataTable)gv.DataSource).Rows.Count.ToString();
        }

        private void btSeleccionar_Click(object sender, EventArgs e)
        {
            if (gv.SelectedRows.Count == 1)
            {
                Vale = Stock.GetVale((int)gv.SelectedRows[0].Cells["Id"].Value);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
        }

        private void btCerrar_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }
    }
}
